package com.qs.questionnairesurveysystem.mapper;

import com.qs.questionnairesurveysystem.entity.Admin;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdminMapper {

    @Insert("INSERT INTO admin (name, department, history, limit, password) VALUES (#{name}, #{department}, #{history}, #{limit}, #{password})")
    int insertAdmin(Admin admin);

    @Update("UPDATE admin SET name = #{name}, department = #{department}, history = #{history}, limit = #{limit}, password = #{password} WHERE adminId = #{adminId}")
    int updateAdmin(Admin admin);

    @Delete("DELETE FROM admin WHERE adminId = #{adminId}")
    int deleteAdmin(Long adminId);

    @Select("SELECT * FROM admin WHERE adminId = #{adminId}")
    Admin findById(Long adminId);

    @Select("SELECT * FROM admin")
    List<Admin> findAll();

    @Select("SELECT * FROM admin WHERE name = #{username}")
    Admin getAdminByName(String username);
}
